//
//  frameworkHelper.m
//  frameworkKit
//
//  Created by GuoMS on 2018/6/23.
//  Copyright © 2018年 GuoMs. All rights reserved.
//

#import "frameworkHelper.h"

@implementation frameworkHelper

+ (NSBundle *)resBundle:(Class)classtype {
    static NSBundle *framworkBundle = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        framworkBundle = [NSBundle bundleForClass:classtype];
        if (framworkBundle) {
            NSString *resourceBundlePath = [framworkBundle pathForResource:@"frameworkHelper" ofType:@"bundle"];
            if (resourceBundlePath && [[NSFileManager defaultManager] fileExistsAtPath:resourceBundlePath]) {
                framworkBundle = [NSBundle bundleWithPath:resourceBundlePath];
            }
        }
    });
    return framworkBundle;
}

+ (UIImage*)imageName:(NSString*)name {
    
    if (name.length == 0) {
        return nil;
    }
    NSBundle *bundle = [frameworkHelper resBundle:[self class]];
    NSString *path = [bundle pathForResource:name ofType:@"png"];
    
    return [UIImage imageWithContentsOfFile:path];
}

@end
